#   This file is a part of Neutrino - a lightweight UI library accelerated with OpenGL
#   Copyright (C) 2023 bsolos
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <https://www.gnu.org/licenses/>.

project('neutrino', ['c', 'cpp'], default_options: ['cpp_std=c++20'])

common_include_dirs = [
    'include'
]

common_deps = [
    dependency('glfw3', required : true)
]

find_program('xxd') # embed.sh requires xxd
embed = find_program('embed.sh')
embed_files = custom_target(
    'resources.[ch]',
    output: ['resources.c', 'resources.h'],
    input: [
        'src/shaders/surface.vert',
        'src/shaders/surface.frag'
    ],
    command: [embed, '@OUTPUT0@', '@OUTPUT1@', '@INPUT@']
)

glad_lib = static_library(
    'neutrino-glad', 
    'src/glad/glad.c', 
    include_directories: common_include_dirs
)

neutrino_slib = shared_library(
    'neutrino',
    'src/render_context.cpp',
    'src/surface.cpp',
    'src/shader.cpp',
    embed_files, # resources.c, resources.h
    link_with: glad_lib , 
    dependencies: common_deps, 
    include_directories: common_include_dirs
)

executable(
    'sample-app', 
    'src/sample_app.cpp', 
    link_with: neutrino_slib, 
    dependencies: common_deps, 
    include_directories: common_include_dirs
)
